import base64
import os

from django.core.mail import send_mail
from django.http import HttpResponse

from Django电商平台.settings import DEFAULT_FROM_EMAIL
import django

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Django电商平台.settings')
django.setup()


class Mail():
    def __init__(self, message, recipient):
        self.message = message
        self.recipient = recipient

    def send(self):
        result = send_mail(subject='验证码信息', message=self.message, from_email=DEFAULT_FROM_EMAIL,
                           recipient_list=[self.recipient, ], fail_silently=False)
        return result


if __name__ == '__main__':
    mail = Mail(message='2333', recipient='904446156@qq.com')
    result = mail.send()
    print(result)
